﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GMaps
{
    public class GMarker:GElement 
    {
        public GLatLng  Position { get; set; }
        public string  Title { get; set; }
        public GMap  Map { get; set; }

        public GMarker() { }
        public GMarker(string id,GMap map, GLatLng position, string title)
        {
            ID = id;
            Map=map;
            Position = position;
            Title = title; 
        }

        public string Render()
        {
            string script = "var " + ID + "= CreateMarker(" + RenderOptions() + ");";
            return script;
        }

        private string RenderOptions()
        {
            return "{position: new " + Position.Render() + ",map: " + Map.ID + ",title:'" + Title + "'" + "}";
        }
        public string RenderJson()
        {
            return "{\"id\":\""+ID+"\",\"position\": " + Position.RenderJson() + ",\"map\": \"" + Map.ID + "\",\"title\":\"" + Title + "\"}";
        }
    }
}
